<?php
$smarty->configLoad($lang . '/events.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['edit_events'];
$sql = 'SELECT * FROM '.DB_CMS.'.module_events WHERE id = :id';
$dbh = $connection->prepare($sql);
$dbh->bindValue(':id', $_GET['id']);
$dbh->execute();foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	$value[] = $row;
}
$smarty->assign('value', $value);

if(isset($_POST['submit'])) {
    $main->logAction($_SESSION['id'], 'event_edit_log');
    $sql = 'UPDATE '.DB_CMS.'.module_events SET title = :title, beginn = :beginn, end = :end, story = :story WHERE id = :id';
	$dbh = $connection->prepare($sql);
    $dbh->bindValue(':title', $_POST['title']);
    $dbh->bindValue(':beginn', $_POST['beginn']);
    $dbh->bindValue(':end', $_POST['end']);
    $dbh->bindValue(':story', $_POST['story']);
	$dbh->bindValue(':id', $_GET['id']);
    $dbh->execute();
    $main->jqmodal('events');
    echo '<meta http-equiv="refresh" content="5; URL=index.php?mod=events">';
}

$template = 'events/edit.tpl';
?>
